home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Demos / A.D. Software / OOFILE / Buildable, limited OOFILE / samples / ooftst05.cpp < prev    next >
C/C++ Source or Header  |  1996-03-07  |  2KB  |  71 lines

  1. // Copyright 1994 A.D. Software. All Rights Reserved
  2.  
  3. // OOFTEST5
  4.  
  5. // Simple stream I/O is used to interact with the user.
  6. // to demonstrate the date parsing
  7.  
  8. #include "oofile.hpp"
  9.  
  10. void getStringMaybeBlank(char* readInto);
  11.  
  12. int 
  13. main()
  14. {
  15.     cout << "OOFILE Validation Suite - Test 5\n"
  16.          << "Today's date is : " << dbDate::today << endl << endl
  17.          << "Simple test to try the input routines of the dbDate type" << endl << endl
  18.          << "A number of sample entries are shown." 
  19.          << endl << endl;
  20.  
  21.     unsigned short year, month, day;
  22.  
  23.     cout << "change the default date order to Month, Day Year" << endl;
  24.  
  25.     dbDate::sDefaultDateOrder=dbDate::orderMDY;
  26.  
  27.     char *     test[] = {    "Jan 15 2001",
  28.                         "Feb, 24, 1923",
  29.                         "3/2/67",
  30.                         "4-30-1988",
  31.                         "MAY12:1971",
  32.                         "June17",
  33.                         "september 4th",
  34.                         "oct 1st 38",
  35.                         "11/19"        };
  36.     unsigned short numtests = 9;
  37.     
  38.     oofDate aDate;  // define a standalone date variable
  39.     aDate = dbDate::currentDate();
  40.     
  41.     cout << "The current date is: " << aDate << endl;
  42.     oofDate twoWeeksAgo = aDate-14;
  43.     
  44.     cout << "Two weeks ago was: " << twoWeeksAgo << endl;
  45.     
  46.     for (int i = 0; i < numtests; ++i) {
  47.         cout << "Attempting to process the date: " << test[i] << endl;
  48.         if (dbDate::chars2ymd(test[i],year,month,day))
  49.             cout << " = (YMD) " << year << "/" << month << "/" << day << endl << endl;
  50.         else
  51.             cout << "bad date" << endl;
  52.     }
  53.  
  54. /*
  55. // uncomment this section if you want to try entering dates yourself    
  56.     for (;;) {
  57.         cout << "Enter a date (MDY): " << flush;
  58.         if (dbDate::istream2ymd(cin, year, month, day)) {
  59.             cout << " = (YMD) " << year << "/" << month << "/" << day << endl << endl;
  60.             cin.ignore(INT_MAX, '\n');
  61.             cin.clear();
  62.         }
  63.         else {
  64.             cout << "bad date" << endl;
  65.             break;
  66.         }
  67.     }
  68. */
  69.     cout << endl << "done" << endl;
  70.     return EXIT_SUCCESS;
  71. }